package org.ms.userservice.service.impl;
import org.ms.userservice.dao.UserMapper;
import org.ms.userservice.model.User;
import org.ms.userservice.service.userService;
import org.ms.userservice.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class userServiceImpl implements userService {
    @Autowired
    UserMapper userMapper;
    @Override
    public ResponseResult login(User user) {
        User user1  = userMapper.selectByUsernameAndPassword(user);
        if (user1 != null){
            return new ResponseResult("200","登陆成功",user1);
        }
        return new ResponseResult("404","登陆失败");
    }

    @Override
    public ResponseResult register(User user) {
        int i = userMapper.insertSelective(user);
        if(i == 1){
            return new ResponseResult("200","注册成功");
        }
        return new ResponseResult("404","注册失败");
    }


}
